import {AfterViewInit, Component, OnDestroy, OnInit} from '@angular/core';
import {Message} from '../../../../../../ng-tools/src/message/message';
import {DynamicComponent, DynamicComponentEvent} from '../../../../../../ng-tools';
import {Subscription} from 'rxjs';
import {ShowFormattedDataOptions} from '../../../../../../ng-tools/src/components/show-formatted-data/show-formatted-data.component';
import {DvbConfigFormatterService} from '../../../../../services/formatter/dvb-config-formatter.service';

@Component({
  selector: 'dvb-channel-info',
  templateUrl: './dvb-channel-info.component.html',
  styleUrls: ['./dvb-channel-info.component.scss']
})
export class DvbChannelInfoComponent implements OnInit, AfterViewInit, OnDestroy, Message, DynamicComponent {
  context: any;
  formatterData;
  dynamic: true;
  set data(value) {
    this.formatterData = value;
  }
  events: DynamicComponentEvent;
  subscriptions: Subscription;
  showFormattedDataOptions: ShowFormattedDataOptions;
  dvbConfigFormatter;
  constructor(private dvbFormatterService: DvbConfigFormatterService) {
    this.dvbConfigFormatter = [
        this.dvbFormatterService.name,
        this.dvbFormatterService.delivery_system,
        this.dvbFormatterService.freq,
        this.dvbFormatterService.srate,
        this.dvbFormatterService.coderate,
        this.dvbFormatterService.multicast_iface4,
        this.dvbFormatterService.common_port,
        this.dvbFormatterService.status,
    ];
    this.showFormattedDataOptions = {
      formatter: this.dvbConfigFormatter,
      data: null,
      split: [3, 9],
      showCopy: true
    };
  }

  ngOnInit() {
  }

  ngAfterViewInit(): void {
    this.showFormattedDataOptions.data = this.formatterData;
  }

  ngOnDestroy(): void {
  }

}
